CREATE TABLE [dbo].[tb_RegimenLaboral]
(
[idRegimenLaboral] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updatetb_RegimenLaboral] ON [dbo].[tb_RegimenLaboral]
 FOR UPDATE AS 
SET NOCOUNT ON
 IF (update(idRegimenLaboral)) begin 
	 SELECT * FROM inserted 
	 IF @@ROWCOUNT = 1 begin 
		 UPDATE tb_Plazas
		 SET RegimenLaboral = (SELECT idRegimenLaboral FROM inserted)
		 WHERE tb_Plazas.RegimenLaboral = (SELECT idRegimenLaboral FROM deleted)
		 UPDATE tb_AperturasDeReestructura
		 SET RegimenLaboral = (SELECT idRegimenLaboral FROM inserted)
		 WHERE tb_AperturasDeReestructura.RegimenLaboral = (SELECT idRegimenLaboral FROM deleted)
		 UPDATE tb_FuncionesLUI
		 SET RegimenLaboral = (SELECT idRegimenLaboral FROM inserted)
		 WHERE tb_FuncionesLUI.RegimenLaboral = (SELECT idRegimenLaboral FROM deleted)
	end  ELSE begin 
		 ROLLBACK TRANSACTION 
 end 
 end

GO
ALTER TABLE [dbo].[tb_RegimenLaboral] ADD CONSTRAINT [PK_tb_RegimenLaboral] PRIMARY KEY NONCLUSTERED  ([idRegimenLaboral]) ON [PRIMARY]
GO
